﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Controllers;
using Infrastructure;
using Infrastructure.DataTypes;
namespace RecommenderSystem
{
    public delegate void ButtonSetScoresEventHandler(User<Discrete> A_userID);
    public partial class CreateUserWithScores : Form
    {
        public event ButtonSetScoresEventHandler ButtonClicked;
        User<Discrete> m_user;
        Dispatcher m_data;
        public CreateUserWithScores()
        {
            InitializeComponent();
            groupBoxItems.Visible = false;
            
        }

        public CreateUserWithScores(Dispatcher data)
        {
            InitializeComponent();
            m_data = data;
            groupBoxItems.Visible = true;
            groupBoxItems.Enabled = false;
            DataSetLoaderMovieLens temp = new DataSetLoaderMovieLens();

            foreach (string item in temp.m_geners)
            {
                checkedListBox1.Items.Add(item);
            }
        }


        private void buttonGnU_Click(object sender, EventArgs e)
        {
            m_user = m_data.GenerateUserID();
            labelUser.Text = "Generated User ID:" + m_user.UserID;
            groupBoxItems.Visible = true;
            groupBoxItems.Enabled = true;
        }

        private void buttonScores_Click(object sender, EventArgs e)
        {

            for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
            {
                m_data.AddNewScoreToDataSetByRelatedGenre(m_user.UserID, checkedListBox1.CheckedItems[i].ToString());
            }
           // MessageBox.Show("Scores were saved");
            MyMessageBox msgBox = new MyMessageBox("Scores were saved", "Scores Saved");
            msgBox.ShowDialog();

            if (ButtonClicked!=null)
            {
                ButtonClicked(m_user);
            }
            this.Close();
        }

        private void CreateUserWithScores_Load(object sender, EventArgs e)
        {

        }
    }
}
